package unittest
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.utils.getTimer;
	
	import shooting.ui.MissileContainer;
	import shooting.ui.missile.IMissile;
	import shooting.ui.missile.MissaleBase;
	public class UnitTest_MissileContainer extends Sprite
	{
		private var testBtn:Sprite;
		private var msContainer:MissileContainer;
		
		private var testCount:Number = 0;
		private var startTimer:Number;
		
		public function UnitTest_MissileContainer()
		{
			super();
			onInit();
		}
		private function onInit():void
		{
			msContainer = new MissileContainer();
			msContainer.setArea(0,0,800,600);
			var i:uint;
			var leng:uint = 3000;
			var ms:IMissile;
			for( i = 0; i < leng; i++)
			{
				ms = new MissaleBase("",new Point(100,100),0);
				msContainer.addMissile(ms);
			}
			testBtn = new Sprite();
			testBtn.graphics.beginFill(0xff0000);
			testBtn.graphics.drawRect(0,0,10,10);
			testBtn.graphics.endFill();
			testBtn.y = 20;
			this.addChild(testBtn);
			testBtn.addEventListener(MouseEvent.CLICK, startTest);
		}
		private function startTest(e:Event):void
		{
			startTimer = getTimer();
			this.addEventListener(Event.ENTER_FRAME, enterFrame_Handler);
		}
		private function enterFrame_Handler(e:Event):void
		{
			testCount++;
			msContainer.render();
			if(testCount > 100)
			{
				this.removeEventListener(Event.ENTER_FRAME, enterFrame_Handler);
				testCount = 0;
				trace(getTimer() - startTimer);
				//1683, 1684, 1684, 1683, 1678
				//3779, 3748, 3667, 3649, 3947
				//3985, 4392, 4446, 4516, 4509
				
				//4066, 4184, 4071, 4087, 4473
				//3974, 4181, 4045, 4243, 4121
				//3935, 3943, 4104, 3999, 4042
			}
		}
	}
}